package org.luxor.commons.workflow.entity;

import javax.validation.constraints.NotBlank;
import java.util.Date;

/**
 * 转办
 *
 * @author Mr.yan  @date 2021/10/19
 */
public class TurnTodoTask {

    /**
     * 任务ID
     */
    @NotBlank(message = "任务ID(taskId)，不能为空")
    private String taskId;

    /**
     * 委托人(即:当前任务办理人)
     */
    @NotBlank(message = "办理人(userId)，不能为空")
    private String userId;

    /**
     * 目标任务-受理人
     */
    private String assignee;

    /**
     * 目标任务-候选人
     */
    private Candidate candidate;

    /**
     * 任务到期时间
     */
    private Date dueDate;

    /**
     * 任务优先级
     */
    private Integer priority;

    /**
     * 转办理由
     */
    private String reason;

    public TurnTodoTask() {
        this.candidate = new Candidate();
    }

    public TurnTodoTask(String taskId, String userId) {
        this();
        this.taskId = taskId;
        this.userId = userId;
    }

    public TurnTodoTask(String taskId, String userId, String targetAssignee) {
        this(taskId, userId);
        this.assignee = assignee;
    }

    public String getTaskId() {
        return taskId;
    }

    public void setTaskId(String taskId) {
        this.taskId = taskId;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getAssignee() {
        return assignee;
    }

    public void setAssignee(String targetAssignee) {
        this.assignee = targetAssignee;
    }

    public Candidate getCandidate() {
        return candidate;
    }

    public void setCandidate(Candidate candidate) {
        if (candidate == null) {
            this.candidate = new Candidate();
        } else {
            this.candidate = candidate;
        }
    }

    public void addCandidateUser(String userId) {
        this.candidate.addUser(userId);
    }

    public void addCandidateGroup(String groupId) {
        this.candidate.addGroup(groupId);
    }

    public Date getDueDate() {
        return dueDate;
    }

    public void setDueDate(Date dueDate) {
        this.dueDate = dueDate;
    }

    public Integer getPriority() {
        return priority;
    }

    public void setPriority(Integer priority) {
        this.priority = priority;
    }

    @Override
    public String toString() {
        return "TurnTodoTask{" +
                "taskId='" + taskId + '\'' +
                ", userId='" + userId + '\'' +
                ", assignee='" + assignee + '\'' +
                ", candidate=" + candidate +
                ", dueDate='" + dueDate + '\'' +
                ", priority=" + priority +
                ", reason='" + reason + '\'' +
                '}';
    }
}
